package day0;
import org.junit.Test;

public class Day4 {
	
	public static void main(String[] args) {

		int[] array = { 23, 56, 8, 23, 99, -23, 2 };
		int[] array1 = { 21, 5, 81, 2, 90, -3, 22 };
		
		int result1 = test1(array);
		
		System.out.println("-----------------------------");
		
		int result2 = test1(array1);
		
		
	}
	
	//把完成一个功能的代码放在一起，可以以“方法名（参数）”被多次调用
	//一个方法尽量只做一件事且可以反复调用

	public static  int test1(int[] array) {
		
		int max = array[0];// 最大值
		int min = array[0];// 最小值
		for (int i = 0; i < array.length; i++) {
			if (array[i] >= max) {
				max = array[i];
			} else if (array[i] <= min) {
				min = array[i];
			}
		}
		System.out.println("数组最大值为" + max);
		System.out.println("数组最小值为" + min);
		
		return max;
	}
	
	
	public static int max(int[] array) {
		int max = array[0];
		for (int i = 0; i < array.length; i++) {
			if (array[i] >= max) {
				max = array[i];
			} 
		}
		return max;
		//System.out.println("最大值:" + max);
	}
	
	
	
	@Test
	public void test8() {
		//构造一个学生对象
		Student ls = new Student();
		ls.id = 1;
		ls.name = "李烁";
		ls.age = 23;
		ls.className = "Jave1912";
		ls.study();
		
		Student wxj = new Student();
		wxj.id = 2;
		wxj.name = "王玺均";
		wxj.age = 21;
		wxj.className = "Jave1912";
		wxj.num();
		
		Teacher fxt = new Teacher();
		fxt.id = 1;
		fxt.name = "方小腾";
		fxt.age = 32 ; 
		fxt.teach();

		Teacher abm = new Teacher();
		abm.id = 1;
		abm.name = "奥巴马";
		abm.age = 32 ; 
		abm.teach1();
	}
}
